<template>
  <div>
    <panel :header="'最新上映'" :footer="footer" :list="list" type="1" @on-img-error="onImgError"></panel>
  </div>
</template>

<script>
import { Panel } from 'vux'
export default {
  components: {
    Panel
  },
  methods: {
    onImgError (item, $event) {
      console.log(item, $event)
    }
  },
  data () {
    return {
      type: '1',
      list: [],
      footer: {
        title: 'more',
        url: 'http://vux.li'
      }
    }
  },
  mounted () {
    this.axios.get('/api/movie/in_theaters').then((response) => {
      console.log(response.data)
      let data = response.data.subjects
      let list = []
      for (var i in data) {
        list[i] = {}
        list[i].title = data[i].title
        list[i].src = data[i].images.large
        list[i].url = data[i].alt
        list[i].desc = '上映年份：' + data[i].year + '&nbsp&nbsp平均评分：' + data[i].rating.average
      }
      console.log(list)
      this.list = list
    }, response => {
      // error callback
    }
)
  }
}
</script>